﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Security;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class IM_chat : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hfRecipient.Value = Request.QueryString["r"].ToString();
            hfSender.Value = IM.UserName();
            lblTitle.Text = "Chat: " + hfRecipient.Value;
            CS_Code.IMDataContext db = new CS_Code.IMDataContext();
            //gets the recipients info.
            var getRecipient = (from iu in db.IM_Users
                                where iu.User_guid == IM.LoginID(hfRecipient.Value)
                                select new
                                {
                                    icon = iu.buddy_icon_url,
                                    profile = iu.profile_info
                                }).FirstOrDefault();
            if (getRecipient != null)
            {
                if (getRecipient.icon.Length < 5)
                {
                    imgBuddyIcon.Visible = false;
                }
                    imgBuddyIcon.ImageUrl = getRecipient.icon;
                
                ltProfile.InnerHtml = getRecipient.profile;
            }
            else { imgBuddyIcon.Visible = false; }

        }
    }
}
